/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.mortbay.jetty.pico.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Hnmtuan
 */
@Entity
@Table(name = "location")
@NamedQueries({
    @NamedQuery(name = "Location.findAll", query = "SELECT l FROM Location l"),
    @NamedQuery(name = "Location.findByIdLocal", query = "SELECT l FROM Location l WHERE l.idLocal = :idLocal"),
    @NamedQuery(name = "Location.findByLocalName", query = "SELECT l FROM Location l WHERE l.localName = :localName"),
    @NamedQuery(name = "Location.findByLocalDescription", query = "SELECT l FROM Location l WHERE l.localDescription = :localDescription"),
    @NamedQuery(name = "Location.findByLocalState", query = "SELECT l FROM Location l WHERE l.localState = :localState")})
public class Location implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idLocal")
    private String idLocal;
    @Column(name = "LocalName")
    private String localName;
    @Column(name = "LocalDescription")
    private String localDescription;
    @Column(name = "LocalState")
    private Integer localState;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "location")
    private List<Item> itemList;

    public Location() {
    }

    public Location(String idLocal) {
        this.idLocal = idLocal;
    }

    public String getIdLocal() {
        return idLocal;
    }

    public void setIdLocal(String idLocal) {
        this.idLocal = idLocal;
    }

    public String getLocalName() {
        return localName;
    }

    public void setLocalName(String localName) {
        this.localName = localName;
    }

    public String getLocalDescription() {
        return localDescription;
    }

    public void setLocalDescription(String localDescription) {
        this.localDescription = localDescription;
    }

    public Integer getLocalState() {
        return localState;
    }

    public void setLocalState(Integer localState) {
        this.localState = localState;
    }

    public List<Item> getItemList() {
        return itemList;
    }

    public void setItemList(List<Item> itemList) {
        this.itemList = itemList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idLocal != null ? idLocal.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Location)) {
            return false;
        }
        Location other = (Location) object;
        if ((this.idLocal == null && other.idLocal != null) || (this.idLocal != null && !this.idLocal.equals(other.idLocal))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.mortbay.jetty.pico.entities.Location[idLocal=" + idLocal + "]";
    }

}
